﻿<UserControl x:Class="WPLDB.Package.UI.View.ChooseTablesView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:uiModel="clr-namespace:WPLDB.DA.Models.UI;assembly=WPLDB.DA.Models"
             xmlns:daModel="clr-namespace:WPLDB.DA.Models;assembly=WPLDB.DA.Models"
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="600">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="50"></RowDefinition>
            <RowDefinition></RowDefinition>
            <RowDefinition Height="30"></RowDefinition>
            <RowDefinition Height="50"></RowDefinition>
        </Grid.RowDefinitions>
        <!--Page Elements-->
        <Label Content="{Binding Question}" Grid.Row="0" Target="{Binding ElementName=tvTables}" VerticalAlignment="Center"  FontWeight="Bold"></Label>
        <!--Tree View Control-->
        <TreeView x:Name="tvTables" ItemsSource="{Binding TableTreeModel}"  Grid.Row="1" 
                        VirtualizingStackPanel.IsVirtualizing="True"
                        VirtualizingStackPanel.VirtualizationMode="Recycling">
            <TreeView.Resources>
                <HierarchicalDataTemplate DataType="{x:Type uiModel:TableTree}" 
                                          ItemsSource="{Binding ListOfTables}">
                    <StackPanel Orientation="Horizontal">
                        <CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay}" Click="CheckBox_Click" CommandParameter="{Binding Name}"  >
                            <CheckBox.Content>
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="/WPLDB.Package.UI;component/Images/Tables.jpg"></Image>
                                    <TextBlock Text="{Binding Name.Original}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0"></TextBlock>
                                </StackPanel>
                            </CheckBox.Content>
                        </CheckBox>

                    </StackPanel>
                </HierarchicalDataTemplate>
                <DataTemplate DataType="{x:Type daModel:TableModel}">
                    <StackPanel Orientation="Horizontal">
                        <CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay}" Click="CheckBox_Click" CommandParameter="{Binding Name}"  >
                            <CheckBox.Content>
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="/WPLDB.Package.UI;component/Images/Table.jpg"></Image>
                                    <TextBlock Text="{Binding Name.Original}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0"></TextBlock>
                                </StackPanel>
                            </CheckBox.Content>
                        </CheckBox>

                    </StackPanel>
                </DataTemplate>
            </TreeView.Resources>
        </TreeView>
        
        <TextBlock Text="{Binding Description}" Grid.Row="2" VerticalAlignment="Bottom" Padding="0,0,0,5"></TextBlock>
        <TextBox Text="{Binding ClassName, UpdateSourceTrigger=PropertyChanged}" Grid.Row="3" Height="24" VerticalAlignment="Top"></TextBox>
    </Grid>
</UserControl>
